﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            #region common
            List<namevalue> list20basetype = new List<namevalue>
            {
                new namevalue { name="普通",value=0 } ,
                new namevalue {name="担保",value = 1 },
                new namevalue {name="预付",value= 2 }
            };  //0普通  1担保  2预付
            List<namevalue> list22quaneOrShouri = new List<namevalue>
            {
                new namevalue {name="全额",value = 0 },
                new namevalue {name="首日",value= 1 }
            }; //0全额 1首日
            List<namevalue> list23quantianOrchaoshi = new List<namevalue>
            {
                new namevalue {name="全天",value= 0 },
                new namevalue {name="超时",value= 1 }
            }; //0全天 1超时
            List<namevalue> list24chaoliangOrNot = new List<namevalue>
            {
                new namevalue {name="非超量",value= 0 },
                new namevalue {name="超量",value= 1 }
            }; //0超量 1非超量
            #endregion

            List<namevalue> listConvert = new List<namevalue>();

            list20basetype.ForEach(item20=> 
            {
                list22quaneOrShouri.ForEach(item22=> 
                {
                    list23quantianOrchaoshi.ForEach(item23=> 
                    {
                        list24chaoliangOrNot.ForEach(item24=> 
                        {
                            listConvert.Add(new namevalue
                            {
                                name = string.Format("{0},{1},{2},{3}",item20.name,item22.name, item23.name, item24.name),
                                value = item20.value * 1  + item22.value * 4 + item23.value * 8 + item24.value * 16
                            });
                        });
                    });
                });
            });

            listConvert.OrderBy(item=>item.value).ToList().ForEach(item=> 
            {
                Console.WriteLine(string.Format("Danbaotype:{0} ; Desc:{1}" , item.value , item.name));
            });

            Console.Read();
        }


        static void print(int value)
        {
            if ((value & 4) == 4)
            {
                Console.WriteLine("首日");
            }

            if ((value & 4) == 0)
            {
                Console.WriteLine("全额");
            }
            //string ss = Convert.ToString(value, 2);


            //if (!string.IsNullOrWhiteSpace(ss) && ss.Length > 1)
            //{
            //    char ccc = ss[ss.Length - 2];
            //    if ('1'.Equals(ccc) && value!=2)
            //    {
            //        Console.WriteLine(string.Format("{0},首日",value));
            //    }
            //    else
            //    {
            //        Console.WriteLine(string.Format("{0},全额", value));

            //    }
            //}
            //else
            //{
            //    Console.WriteLine(string.Format("{0},全额", value));

            //}

        }
    }
    class namevalue
    {
        public string name { get; set; }
        public int value { get; set; }
    }
    public static class intExtension
    {
        public static string ToBase2(this int num)
        {
            return Convert.ToString(num, 2);
        }
    }
}
